<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8" />
  <meta name="viewport"
    content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  <meta name="format-detection" content="telephone=no,email=no,date=no,address=no" />
  <title>巡查</title>
  <link rel="stylesheet" type="text/css" href="../css/api.css" />
  <link rel="stylesheet" type="text/css" href="../css/style.css" />
  <!-- <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css" /> -->
  <style>
    html,
    body {
      background-color: #f5f6f6;
    }

    /* .content {
      margin-top: 10px;
    } */

    .content td {
      border-bottom: 1px solid #dfe0e0;
      height: 60px;
    }

    .Add {
      height: 40px;
      width: 96%;
      background-color: #1abc9c;
      color: white;
      text-align: center;
      font-size: 15px;
      margin-top: 20px;
      outline: none;
    }

    .ywc {
      background-image: url(../image/yiwancheng.png);
      background-size: 80px;
      background-position: center;
      background-repeat: no-repeat;
    }

    .ycs {
      background-image: url(../image/ycs.png);
      background-size: 80px;
      background-position: center;
      background-repeat: no-repeat;
    }

    .wwc {
      background-image: url(../image/weiwancheng.png);
      background-size: 80px;
      background-position: center;
      background-repeat: no-repeat;
    }

    .renming {
      background-color: #72edd1;
      border: 1px solid #d0f9f0;
      padding: 10px 3px 10px 3px;
      color: #fff;
    }

    [v-cloak] {
      display: none;
    }

    table tr:nth-child(odd) {
      background: #dfdfdf;
    }
  </style>
</head>

<body>
  <div class="content">
    <div id="appsse" v-cloak>
      <table width="100%">
        <tr v-for="(value , index) in object" @click="plus(value.id,value.status)">
          <td width="50" align="center">
            <p>
              {{index+1}}
            </p>
          </td>
          <td width="50" align="center">
            <span class="renming">{{ value.maintenanceTroops }}</span>
          </td>
          <td>
            <p style="height: 20px; overflow: hidden;">
              {{ value.source }}
            </p>
            <p>
              {{ value.publishTime }}
            </p>
          </td>
          <td width="120" class="wwc" v-if="value.status=='2'">
            <p>
              {{ value.receiver }}
            </p>
            <p>
              {{ value.completeTime|dateFormat }}
            </p>
          </td>
          <td width="120" class="ywc" v-if="value.status=='0'">
            <p>
              {{ value.receiver }}
            </p>
            <p>
              {{ value.completeTime|dateFormat }}
            </p>
          </td>
          <td width="120" class="ycs" v-if="value.status=='1'">
            <p>
              {{ value.receiver }}
            </p>
            <p>
              {{ value.completeTime|dateFormat }}
            </p>
          </td>
        </tr>
      </table>
    </div>
  </div>
</body>
<script type="text/javascript" src="../script/common.js"></script>
<script src="../script/ajaxFunction.js"></script>
<script src="../script/jquery-1.11.0.min.js"></script>
<script src="../script/swiper.min.js"></script>
<script src="../script/fontSize.js"></script>
<script src="../script/api.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript" src="../script/jquery-1.11.0.min.js"></script>
<script type="text/javascript">
  apiready = function () {
    api.setRefreshHeaderInfo(
      {
        visible: true,
        bgColor: "rgba(0,0,0,0)",
        textColor: "#666",
        textDown: "下拉刷新",
        textUp: "释放刷新",
      },
      function (ret, err) {
        window.location.reload();
        api.refreshHeaderLoadDone();
      }
    );

    var ret = $api.getStorage("selectpor");
    var areaId = null;
    var reg = $api.getStorage("userSession");
    var sids = reg.data.sysRole.sysRoleCode;
    var role = sids.role_number;
    if (role != "construction") {
      areaId = $api.getStorage("selectpor").id;
    } else {
      areaId = reg.data.areaid;
    }
    //var projectidsss = ret.id;
    var proId = reg.data.proId;
    var uuisid = reg.data.id;
    var uesid = reg.data.enterprise.id;
    var sids = reg.data.sysRole.sysRoleCode.role_number;
    var app = new Vue({
      el: "#appsse",
      data: {
        object: [],
        msg: "",
      },
      created: function () {

        if (sids == "manage") {
          api.ajax(
            {
              url: BaseServiceUrl + "mobile/admin/findAll.json",
              method: "post",
              dataType: "json",
              data: {
                values: {
                  uesid: uesid,
                  areaId: ret.id,
                  proId: proId,
                },
              },
            },
            function (ret, err) {
              if (ret.code == 0) {
                for (var i = 0; i < ret.data.length; i++) {
                  app.object.push(ret.data[i]);
                }
                var reg = $api.getStorage("userSession");
                if (reg != null) {
                  var userid = reg.data.sysRole.sysRoleCode;
                  var roleName = userid.role_number;
                  app.msg = roleName;
                }
              }
            }
          );
        } else if (sids == "construction") {
          var receiverId = reg.data.id;
          api.ajax(
            {
              url: BaseServiceUrl + "mobile/construction/findAll.json",
              method: "post",
              dataType: "json",
              data: {
                values: {
                  uesid: uesid,
                  areaId: areaId,
                  proId: proId,
                  receiverId: receiverId.toString(),
                },
              },
            },
            function (ret, err) {
              if (ret.code == 0) {
                for (var i = 0; i < ret.data.length; i++) {
                  app.object.push(ret.data[i]);
                }
                var reg = $api.getStorage("userSession");
                if (reg != null) {
                  var userid = reg.data.sysRole.sysRoleCode;
                  var roleName = userid.role_number;
                  app.msg = roleName;
                }
              }
            }
          );
        } else if (sids == "enterprise") {
        }
      }, methods: {
        plus: function (id, status) {
          if (status == '2' && sids == 'manage') {
            updatePatrol(id)
          } else if (status == '2' && sids == 'construction') {
            unCompletePatrol(id)
          } else if (status != '2') {
            viewPatrol(id)
          }
        }
      }
    });
  };
  //修改巡查
  function updatePatrol(id) {
    // alert(id);
    var params = {
      id: id,
    };
    openDetail("xuncha/modifyxuncha_window.html", params);
  }
  //施工完成巡查
  function unCompletePatrol(id) {
    var parms = {
      id: id,
    };
    openDetail("xuncha/unCompleteCon_window.html", parms);
  }
  //查看巡查 管理和施工角色    or 领导角色
  function viewPatrol(id) {
    var parms = {
      id: id,
    };
    openDetail("xuncha/viewPatrol_window.html", parms);
  }

  Vue.filter("dateFormat", function (time) {
    if (time != null) {
      var date = new Date(time);
      var year = date.getFullYear();
      /* 在日期格式中，月份是从0开始的，因此要加0
       * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
       * */
      var month =
        date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1;
      var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
      var hours =
        date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
      var minutes =
        date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
      var seconds =
        date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
      // 拼接
      return year + "-" + month + "-" + day;
    } else {
      return "";
    }
  });
</script>

</html>